﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <math.h> 
#include <ctype.h> 
#include <time.h> 
#include <assert.h>

int main()
{
	int n2 = 0;
	scanf("%d", &n2);
	int n = (int)sqrt(n2);
	int arr[n][n];
	int arr1[10] = { 0 };

	//初始化数组为0
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			arr[i][j] = 0;
		}
	}

	int col = n / 2;
	int row = 0;
	for (int i = 1; i <= n2; i++)
	{
		arr[row][col] = i;
		int next_row = row - 1;
		int next_col = col + 1;

		if (next_row < 0)
		{
			next_row = n - 1;
		}

		if (next_col > n - 1)
		{
			next_col = 0;
		}

		if (arr[next_row][next_col] != 0)
		{
			row += 1;

			if (row >= n)
			{
				row = 0;
			}
		}

		else
		{
			row = next_row;
			col = next_col;
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			printf("%d\t", arr[i][j]);
		}
		printf("\n");
	}

	return 0;

}
